AES Key encoded byte[] to String and back to byte[]
Posted
by Tom Brito
on Stack Overflow
See other posts from Stack Overflow
or by Tom Brito
Published on 2010-05-26T17:13:56Z
Indexed on
2010/05/26
17:21 UTC
Read the original article
Hit count: 214
In the similar question "Conversion of byte[] into a String and then back to a byte[]" is said to not to do the byte[] to String and back conversion, what looks like apply to most cases, mainly when you don't know the encoding used.
But, in my case I'm trying to save to a DB the javax.crypto.SecretKey data, and recoverd it after.
The interface provide a method getEncoded() which returns the key data encoded as byte[], and with another class I can use this byte[] to recover the key.
So, the question is, how do I write the key bytes as String, and later get back the byte[] to regenerate the key?
© Stack Overflow or respective owner